package club.banyuan.hrms.dao.impl;

import club.banyuan.hrms.dao.PositionDao;
import club.banyuan.hrms.domain.Admin;
import club.banyuan.hrms.domain.Position;

import java.util.ArrayList;
import java.util.List;

public class PositionDaoImpl implements PositionDao {
    private static List<Position> positions;

    static {
        positions = new ArrayList<>();

        Position position = new Position();
        position.setId(1);
        ;
        position.setName("项目经理");
        position.setDescription("无");
        positions.add(position);

        position = new Position();
        position.setId(2);
        ;
        position.setName("产品经理");
        position.setDescription("无");
        positions.add(position);
    }

    @Override
    public List<Position> getPositions() {
        return positions;
    }

    @Override
    public void updatePosition(Position position) {
        Integer id = position.getId();
        if (id != null) {
            Position existPosition = getPositionById(id);
            existPosition.setName(position.getName());
            existPosition.setDescription(position.getDescription());
        }
    }

    @Override
    public void addPosition(Position position) {
        position.setId(positions.size() + 1);
        positions.add(position);
    }

    @Override
    public Position getPositionById(Integer id) {
        for (Position position : positions) {
            if (position.getId().equals(id)) {
                return position;
            }
        }
        return null;
    }

    @Override
    public void deletePosition(Integer[] ids) {

    }


}
